<template>
  <div id="app">


    <router-view/>
<div class="toTop" @click="toTop()">▲</div>
  
<menus v-show="showMenus()" ></menus>
  </div>
</template>
<script>

</script>


<script>
import menus from './Layout/menu'
export default {
  data:function(){
    return{
      active:0
    }
  },
  methods:{
    toTop:function(){
      window.scrollTo(0,0)
    },
    showMenus:function(){
      if(this.$route.path=='/home'||this.$route.path=='/my'
      ||this.$route.path=='/findshopp'||this.$route.path=='/shoppingCart'
      ||this.$route.path=='/side'
      ){
        return true;
      }
    },
    setActive:function(){
      console.log(this.$router);
    }
  },components: {
    menus
  },
  mounted () {
    window.addEventListener('scroll',()=>{
      let scrollTop=document.body.scrollTop||document.documentElement.scrollTop
       let toTop=document.querySelector('.toTop')
      if(scrollTop>200){
       
        toTop.style.display="block"
      }else{
         toTop.style.display="none"
      }
    })
  },
  created () {
    this.setActive()
    console.log('app------------------');
  },
  watch: {
   $route:{
    handler(val,old){
      console.log(val);
    }
    ,deep:true
   }
  }
}
</script>


<style lang="scss">

.toTop{
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, .5);
  position: fixed;
  right: 30px;
  bottom: 100px;
  color: white;
  border-radius: 100%;
  text-align: center;line-height: 40px;
  display: none;
}

::v-deep .van-submit-bar{
  bottom:50px;
}

nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
